import React, { useState } from "react";
import QRCode from 'qrcode.react';
import {Button} from 'antd';
import './index.css';

function Teacher() {
    const [data, setData] = useState("63bc2ec2214a2136671442db");
    const downloadQrCode = () => {
        const canvasImg = document.getElementById("qrCode");
        const img = new Image();
        img.src = canvasImg.toDataURL("image/png");
        const downLink = document.createElement("a");
        downLink.href = img.src;
        downLink.download = "绑定学校二维码";
        downLink.click();
    };
    return (
        <div>
            <h2>老师管理</h2>
            <div className="qrcode">
                <QRCode value={data} size={256} id="qrCode" />
                <Button type="primary" onClick={downloadQrCode}>
                    保存
                </Button>
                <p>请点击下载保存二维码</p>
            </div>
        </div>
    );
}

export default Teacher;
